git flow migration step 1 recommendation
written by Chat GPT 5
[스텝 1] 최소 셋업(수동 승급 & 자동 배포 최소한)
1) stage
브랜치 생성(메인에서)
-
로컬/리모트 브랜치 생성
git checkout main && git pull origin main git checkout -b stage git push -u origin stage
-
GitHub → Settings > Branches > Branch protection rules
-
main
,stage
,dev
보호: PR 필수, 필수 체크(빌드/테스트), force-push 금지 -
머지 전략: squash(권장)
-
2) 라벨/PR 템플릿/체크리스트 준비
-
GitHub → Issues > Labels:
ready-for-stage
라벨 생성(색상 지정) -
.github/pull_request_template.md
추가(요지)## 변경 요약 - ## 리스크/롤백 - ## 테스트 - [ ] 유닛 - [ ] 통합 - [ ] 수동QA ## 릴리즈노트(사용자/운영자) -
-
stage → main
전용 체크리스트 템플릿(노션/Markdown):-
포함 기능 리스트/PR 링크
-
마이그레이션/플래그 변경 없음(or 절차 기재)
-
알림/모니터링 지표 준비
-
롤백 전략 확인
-
3) dev 기능 분류(출시 가능 vs 대기)
-
규칙: 출시 가능 PR에만 라벨
ready-for-stage
부여(이 시점은 수동) -
PR 제목 컨벤션(권장):
feat(xxx): ... (#123)
→ 릴노 자동화 준비에 도움
4) stage 승급 PR 생성(수동)
-
대상:
ready-for-stage
라벨이 붙은 feature 브랜치(또는 그 머지 커밋) -
방법 A(권장): feature → stage PR
-
방법 B: dev에서 기능 부분만 따서 promotion 브랜치 생성 후 → stage PR
# B 예시: dev에서 특정 PR만 승급하고 싶은 경우 git checkout -b promote/feature-foo origin/stage # dev의 해당 PR 머지 커밋만 cherrypick (스쿼시 머지커밋 기준) git cherry-pick <dev-merge-commit-sha> git push -u origin promote/feature-foo # GitHub에서 base=stage, head=promote/feature-foo 로 PR 생성
5) 스테이징 배포(임시)
-
아직 스테이징 서버 없음 → 배포 스텝은 스킵하고 “빌드/테스트만” 체크.
-
CI(간단 버전) 추가:
.github/workflows/ci-stage.yml
name: CI for Stage PRs on: pull_request: branches: [ "stage" ] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: pnpm i --frozen-lockfile - run: pnpm build - run: pnpm test -- --ci
6) stage → main 머지 & 배포(프로덕션)
-
stage
PR들 머지로 안정화 후, stage → main PR 생성 -
머지 후 태깅
git checkout main && git pull git tag vX.Y.Z -m "Release vX.Y.Z" git push origin vX.Y.Z
-
프로덕션 배포 워크플로(예시):
.github/workflows/deploy-prod.yml
name: Deploy Prod on: push: tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: pnpm i --frozen-lockfile - run: pnpm build - run: ./scripts/deploy.sh prod env: PROD_API_KEY: ${{ secrets.PROD_API_KEY }}
7) main → dev 백머지(자동, PR 없이)
-
간단 자동 백머지 워크플로:
.github/workflows/backmerge-main-to-dev.yml
name: Backmerge main -> dev on: push: tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] jobs: backmerge: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - run: | git config user.name "release-bot" git config user.email "release-bot@users.noreply.github.com" git fetch origin main dev git checkout dev git merge --no-ff --no-edit origin/main || exit 10 - run: pnpm i --frozen-lockfile && pnpm build && pnpm test -- --ci - if: ${{ success() }} run: git push origin dev
-
충돌 시 워크플로가 실패 → 수동 처리(이번 스텝1에서는 PR 미사용 방침이므로 충돌 해결 후 직접
dev
에 푸시)
2025-09-25 promo-to-stage.yml
# .github/workflows/promo-to-stage.yml
name: Promote labeled merges to stage
on:
pull_request:
types: [closed, labeled]
jobs:
promote:
if: >
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'ready-for-stage') &&
github.event.pull_request.base.ref == 'dev'
runs-on: ubuntu-latest
permissions: { contents: write, pull-requests: write }
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: |
git fetch origin dev stage
DEV_MERGE_SHA="${{ github.event.pull_request.merge_commit_sha }}"
BR="promote/${{ github.event.pull_request.head.ref }}"
git switch -c "$BR" origin/stage
git cherry-pick "$DEV_MERGE_SHA"
git push -u origin "$BR"
- name: Open PR to stage
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Promote: ${context.payload.pull_request.title}`,
head: `promote/${context.payload.pull_request.head.ref}`,
base: 'stage',
body: `Auto-promotion of ${context.payload.pull_request.html_url}`
});
목적: Dev 환경에서 검증된 기능을 Stage 환경으로 자동 승격
동작 조건:
- PR이 dev 브랜치로 머지됨
ready-for-stage
라벨이 붙어있음- PR이 closed 상태 (merged=true)
동작 방식:
- Dev에 머지된 커밋(merge_commit_sha)을 가져옴
- Stage 브랜치 기준으로 새 브랜치 생성 (
promote/기존PR브랜치명
) - Cherry-pick으로 해당 커밋만 Stage로 가져옴
- Stage를 향한 새 PR 자동 생성
장점:
- 선택적 프로모션 가능 (라벨이 붙은 것만)
- Dev의 모든 변경사항이 아닌, 특정 기능만 Stage로 이동